<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}协同调度信息系统{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        :root {
            --primary-color: #667eea;
            --secondary-color: #764ba2;
            --success-color: #28a745;
            --info-color: #17a2b8;
            --warning-color: #ffc107;
            --danger-color: #dc3545;
        }
        
        body {
            background-color: #f8f9fa;
        }
        
        .navbar {
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        
        .navbar-brand {
            font-weight: 700;
            font-size: 1.5rem;
        }
        
        .role-badge {
            font-size: 0.8rem;
            padding: 4px 8px;
            border-radius: 15px;
        }
        
        .recon-badge { background-color: var(--success-color); }
        .analyst-badge { background-color: var(--info-color); }
        .decision-badge { background-color: var(--warning-color); color: #333; }
        .executor-badge { background-color: var(--danger-color); }
        
        .main-content {
            margin-top: 20px;
        }
        
        .card {
            border: none;
            border-radius: 15px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.08);
            transition: transform 0.3s ease;
        }
        
        .card:hover {
            transform: translateY(-5px);
        }
        
        /* 防止模态框闪烁 - 彻底修复 */
        .modal {
            transition: none !important;
        }
        
        .modal-dialog {
            transition: none !important;
        }
        
        .modal-content {
            transition: none !important;
        }
        
        .modal-backdrop {
            transition: none !important;
        }
        
        /* 当模态框打开时，禁用所有悬停效果 */
        body.modal-open .card:hover {
            transform: none !important;
        }
        
        body.modal-open .btn:hover {
            transform: none !important;
        }
        
        /* 禁用模态框内所有元素的悬停效果 */
        .modal .card:hover {
            transform: none !important;
        }
        
        .modal .btn:hover {
            transform: none !important;
        }
        
        .card-header {
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            color: white;
            border-radius: 15px 15px 0 0 !important;
            border: none;
        }
        
        .btn-primary {
            background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
            border: none;
            border-radius: 10px;
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
        }
        
        .status-badge {
            font-size: 0.75rem;
            padding: 4px 8px;
            border-radius: 10px;
        }
        
        .status-pending { background-color: #ffc107; color: #333; }
        .status-analyzed { background-color: #17a2b8; color: white; }
        .status-completed { background-color: #28a745; color: white; }
        .status-failed { background-color: #dc3545; color: white; }
        
        .priority-badge {
            font-size: 0.75rem;
            padding: 4px 8px;
            border-radius: 10px;
        }
        
        .priority-low { background-color: #6c757d; color: white; }
        .priority-medium { background-color: #ffc107; color: #333; }
        .priority-high { background-color: #fd7e14; color: white; }
        .priority-critical { background-color: #dc3545; color: white; }
    </style>
    {% block extra_css %}{% endblock %}
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('index') }}">
                <i class="fas fa-shield-alt"></i> 协同调度信息系统
            </a>
            
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    {% if current_user.is_authenticated %}
                        {% if active_role == 'recon' %}
                            <li class="nav-item">
                                <a class="nav-link" href="{{ url_for('recon_dashboard') }}">
                                    <i class="fas fa-search"></i> 侦察工作台
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="{{ url_for('add_recon_data') }}">
                                    <i class="fas fa-plus"></i> 提交侦察数据
                                </a>
                            </li>
                        {% elif active_role == 'analyst' %}
                            <li class="nav-item">
                                <a class="nav-link" href="{{ url_for('analyst_dashboard') }}">
                                    <i class="fas fa-chart-line"></i> 分析工作台
                                </a>
                            </li>
                        {% elif active_role == 'decision' %}
                            <li class="nav-item">
                                <a class="nav-link" href="{{ url_for('decision_dashboard') }}">
                                    <i class="fas fa-gavel"></i> 决策工作台
                                </a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="{{ url_for('create_order') }}">
                                    <i class="fas fa-plus"></i> 下达指令
                                </a>
                            </li>
                        {% elif active_role == 'executor' %}
                            <li class="nav-item">
                                <a class="nav-link" href="{{ url_for('executor_dashboard') }}">
                                    <i class="fas fa-cogs"></i> 执行工作台
                                </a>
                            </li>
                        {% endif %}
                    {% endif %}
                </ul>
                
                <ul class="navbar-nav">
                    {% if current_user.is_authenticated %}
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('logs') }}">
                                <i class="fas fa-list"></i> 系统日志
                            </a>
                        </li>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown">
                                <i class="fas fa-user"></i> {{ current_user.username }}
                                {% if active_role %}
                                <span class="role-badge {{ active_role }}-badge">
                                    {% if active_role == 'recon' %}侦察员
                                    {% elif active_role == 'analyst' %}分析员
                                    {% elif active_role == 'decision' %}决策员
                                    {% elif active_role == 'executor' %}执行员
                                    {% endif %}
                                </span>
                                {% endif %}
                            </a>
                            <ul class="dropdown-menu">
                                <li><a class="dropdown-item" href="{{ url_for('select_role') }}">
                                    <i class="fas fa-user-shield"></i> 切换身份
                                </a></li>
                                <li><a class="dropdown-item" href="{{ url_for('logout') }}">
                                    <i class="fas fa-sign-out-alt"></i> 退出登录
                                </a></li>
                            </ul>
                        </li>
                    {% else %}
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('login') }}">
                                <i class="fas fa-sign-in-alt"></i> 登录
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>

    <div class="container main-content">
        {% with messages = get_flashed_messages() %}
            {% if messages %}
                {% for message in messages %}
                    <div class="alert alert-info alert-dismissible fade show" role="alert">
                        {{ message }}
                        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                    </div>
                {% endfor %}
            {% endif %}
        {% endwith %}

        {% block content %}{% endblock %}
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    
    <script>
    // 防止模态框闪烁的完整修复
    document.addEventListener('DOMContentLoaded', function() {
        // 禁用所有模态框的过渡动画
        var style = document.createElement('style');
        style.textContent = `
            .modal, .modal-dialog, .modal-content, .modal-backdrop {
                transition: none !important;
                animation: none !important;
            }
        `;
        document.head.appendChild(style);
        
        // 监听模态框事件，确保body类正确设置
        document.addEventListener('show.bs.modal', function(e) {
            document.body.classList.add('modal-open');
        });
        
        document.addEventListener('hide.bs.modal', function(e) {
            document.body.classList.remove('modal-open');
        });
        
        // 防止模态框按钮重复点击
        document.querySelectorAll('[data-bs-toggle="modal"]').forEach(function(button) {
            button.addEventListener('click', function(e) {
                // 防止快速重复点击
                if (this.disabled) {
                    e.preventDefault();
                    return false;
                }
                this.disabled = true;
                setTimeout(function() {
                    button.disabled = false;
                }, 500);
            });
        });
    });
    </script>
    
    {% block extra_js %}{% endblock %}
</body>
</html>